<template>
    <el-form label-width="80px">
        <el-form-item label="药品名称:">
            <el-input type="text" v-model="drugs.drugsName" />
        </el-form-item>
        <el-form-item label="药品描述:">
            <el-input type="text" v-model="drugs.drugsContent" />
        </el-form-item>
        <el-form-item label="生产公司:">
            <el-input type="text" v-model="drugs.drugsCom" />
        </el-form-item>
        <el-form-item label="生产地址:">
            <el-input type="text" v-model="drugs.drugsAddress" />
        </el-form-item>
        <el-form-item label="药品价格:">
            <el-input-number :min="0" v-model="drugs.drugsPrice" />
        </el-form-item>
        <el-form-item label="药品库存:">
            <el-input-number :min="0" v-model="drugs.drugsCount" />
        </el-form-item>
        <el-form-item label="确认操作:">
            <el-button style="width: 100%" @click="addDrugs">
                确认修改
            </el-button>
        </el-form-item>
    </el-form>
</template>

<script>
    import utils from "@/Utils";
    export default {
        name: "SystemPopupAddDrugs.vue",
        data(){
            return{
                drugs:{
                    drugsName:'',
                    drugsContent:'',
                    drugsCom:'',
                    drugsAddress:'',
                    drugsPrice:0,
                    drugsCount:0
                },
                utils
            }
        },
        methods:{
            addDrugs:function () {
                const drugs=this.drugs;
                if (this.utils.isEmpty(drugs.drugsName,drugs.drugsCount,drugs.drugsPrice,drugs.drugsAddress,drugs.drugsCom,drugs.drugsContent)) {
                    this.utils.tipsMessage("请不要留空",1);
                    return
                }
                this.axios.post("/Drugs/isLogin/isSystemAndDrugs/addDrugs",{
                    drugsName:drugs.drugsName,
                    drugsContent:drugs.drugsContent,
                    drugsCom:drugs.drugsCom,
                    drugsAddress:drugs.drugsAddress,
                    drugsPrice:drugs.drugsPrice,
                    drugsCount:drugs.drugsCount
                }).then((req)=>{
                    const data=req.data;
                    if(data.code>0){
                        this.utils.tipsMessage(data.error,data.code);
                        return
                    }
                    this.utils.tipsMessage(data.data,data.code);
                    this.drugs={
                        drugsName:'',
                        drugsContent:'',
                        drugsCom:'',
                        drugsAddress:'',
                        drugsPrice:0,
                        drugsCount:0
                    };
                })
            }
        }
    }
</script>

<style scoped>

</style>